module.exports = function ({
  method = 'GET',
  url,
  data = {},
}) {
  // 成功resolve，失败reject的回调函数
  return new Promise((resolve, reject) => {
    wx.showLoading({
      title: '加载中',
    });

    wx.request({
      url,
      method,
      data,
      success: res => {
        resolve(res.data);
      },
      fail: err => {
        
        reject(err);
      },
      complete: () => {
        wx.hideLoading();
      },
    });
  });
};